package com.uhylab.uhuvinetest.utils.sharedpreutils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by xyb on 15/12/8 at UHylab
 *
 * @version 1.0
 */
public class SharedPreUtils {
    private static final String PREF_NAME = "config";

    public static boolean getBoolean(Context context, String key,
                                     boolean defaulfValue) {
        SharedPreferences sharedPreferences =
                context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        return sharedPreferences.getBoolean(key, defaulfValue);
    }

    public static String getString(Context context, String key,
                                   String defaulfValue) {
        SharedPreferences sharedPreferences =
                context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        return sharedPreferences.getString(key, defaulfValue);
    }





    public static void setBoolean(Context context, String key,
                                  boolean value) {
        SharedPreferences sharedPreferences =
                context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        sharedPreferences.edit().putBoolean(key, value).commit();
    }

    public static void setString(Context context, String key,
                                 String value) {
        SharedPreferences sharedPreferences =
                context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        sharedPreferences.edit().putString(key, value).commit();
    }

    public static void setInt(Context context, String key, int value) {
        SharedPreferences sharedPreferences =
                context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        sharedPreferences.edit().putInt(key, value).commit();
    }

    public static int getInt(Context context, String key,
                                   int defaulfValue) {
        SharedPreferences sharedPreferences =
                context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        return sharedPreferences.getInt(key, defaulfValue);
    }
}
